const app = getApp()
let qCloud = require("../../../index.js");
let cityList = require("../../../lib/city.js");
let cityData=[];
Page({

   /**
    * 页面的初始数据
    */
   data: {
      imgPath: qCloud.config.STATIC_IMAGE_PATH,
      regiontxt: "请选择省市县",
      provincetxt: "省",
      citytxt: "市",
      areatxt: "县",
      provinceIndex:0,
      cityIndex:0,
      cityList:[],
      addflag:true,
      sizeadd:"",
      numadd:0,
      priceadd:"",
      moneyadd:"",
      sizeListArr:[
         {id:1,size:"XS",num:"200",price:50,money:100} ,
         {id:2,size:"S",num:"200",price:50,money:100} ,
         {id:3,size:"M",num:"200",price:50,money:100} ,
         {id:4,size:"L",num:"200",price:50,money:100} ,
         {id:5,size:"XL",num:"200",price:50,money:100}
      ]
   },

   bindProvinceChange: function (e) {
      let self=this;
      let index = e.detail.value;
      let provincetxt=cityData[index]["name"];
      this.setData({
         provincetxt: provincetxt,
         cityList:cityData[index]["sub"],
         provinceIndex:index
      })
   },

   bindCityChange: function (e) {
      let self=this;
      let index = e.detail.value;
      let cityList=self.data.cityList;
      let areaList=cityList[index]["sub"];
      let citytxt=cityList[index]["name"];
      this.setData({
         citytxt: citytxt,
         cityIndex:index,
         areaList:areaList
      })
   },


   bindAreaChange: function (e) {
      let self=this;
      let index = e.detail.value;
      let areaList=self.data.areaList;
      let areatxt=areaList[index]["name"];
      this.setData({
         areatxt: areatxt,
         areaIndex:index
      })
   },

   delTap(e){
      let self=this
      let index=e.currentTarget.dataset.index
      let sizeListArr=self.data.sizeListArr
      sizeListArr.splice(index,1);
      self.setData({
         sizeListArr:sizeListArr
      })
   },
   addTap(){
      this.setData({
         addflag:true
      })
   },
   cancelTap(){
      this.setData({
         addflag:false,
         name:"",
         desc:""
      })
   },
   dosubmit(){
      wx.navigateTo({
        url: "/pages/enterprise/index",
      })
   },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
      let self=this
      cityList.init(self);
      cityData=self.data.cityData
   },

   /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {

   },

   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {

   },

   /**
    * 生命周期函数--监听页面隐藏
    */
   onHide: function () {

   },

   /**
    * 生命周期函数--监听页面卸载
    */
   onUnload: function () {

   },

   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {

   },

   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {

   },

   /**
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {

   }
})
